<?php
$this->headTitle('Quản lý thiết bị','append');
?>
<!-- Start Table -->
<div class="grid grid_8">
    <div id="tabs-search">
      <ul class="tabs-menu">
        <li class="active" id="tabs-1"><span>Thống kê thiết bị dự án theo nhóm thiết bị</span></li>
      </ul>
      <div class="tabs tabs-1">
            <form class='frm-search frm-search-equipment' name='frm-search' action='' method="get" enctype="application/x-www-form-urlencoded">
                <div class='search-option-wrapper'>	
                	<div style="clear: both"></div>
                	<ul class='search-option-select'>
                		<li class="first">
                			<label>Nhóm thiết bị</label>
                        </li>
                        <?php foreach($this->categoryList as $cate){ ?>
            			<li>
            				<label><?php echo $cate['categoryName'];?></label>
            				<input class="checkbox" type="checkbox" name="categoryId[]" value="<?php echo $cate['categoryId'];?>" <?php echo (isset($this->categorySearch) && in_array($cate['categoryId'], $this->categorySearch)) ? 'checked="checked"' : '';?>/>
            			</li>
                        <?php } ?>
                        <li class="button">
                            <input type="submit" name="submit" class="submit" value="Tìm kiếm" />
                        </li>
                	   <div style="clear: both"></div>
                	</ul>
                	<div style="clear: both"></div>
                </div>
            </form>
      </div>
    </div>
    <?php if($this->categorySearch){ ?>
    <div class="box table" style="margin-top: 20px;">
        <table cellspacing="0" class="content_equipment">
        	<thead id="detail">
        		<tr>
                    <td rowspan="2">Dự án</td>
                    <?php
                        foreach($this->ownerList as $row){
                            echo '<td colspan="',count($this->categorySearch),'" style="border-bottom: 0px;">',$row->name,'</td>';
                        }
                    ?>
        		</tr>
                <tr>
                    <?php
                        foreach($this->ownerList as $row){
                            foreach($this->arrCate as $cate){
                                echo '<td>',$cate.'</td>';
                            }
                        }
                    ?>
                </tr>
        	</thead>
        	<tbody>
                <?php
                    $temp = 'odd';
                    foreach($this->projectList as $project){
                        echo '<tr class="row-',$temp,'"><td>',$project['projectName'],'</td>';
                        foreach($this->ownerList as $owner){
                            foreach($this->categorySearch as $cate){
                                if(isset($this->arrCountEquipment[$project['projectId']][$owner->code][$cate]) && $this->arrCountEquipment[$project['projectId']][$owner->code][$cate]){
                                    $count = $this->arrCountEquipment[$project['projectId']][$owner->code][$cate];
                                }else{
                                    $count = '-';
                                }
                                echo '<td align="right">',$count,'</td>';
                                
                            }
                        }
                        echo '</tr>';
                        if($temp == 'odd')
                            $temp = 'even';
                        else
                            $temp = 'odd';
                    }
                ?>
            </tbody>
        </table>
    	<p align="center" style="clear:none;">
            <a style="text-decoration: none; color: #1f92ff;" href='<?php echo $this->url(array('action'=>'statisticexport','categoryId'=>$this->categorySearch))?>' title="xuất Excel">
                <img src='image/icons/small/icon_table-export.png' /><br />Xuất file excel
            </a>
        </p>
    </div>
    <?php } ?>
</div>
<script>
	var w = $(".content_equipment").width();
	$(".grid .box.table").css('width', w);
</script>
